import 'package:flutter/material.dart';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:dio/dio.dart';


class SelfR extends StatefulWidget {
  @override
  _SelfRState createState() => _SelfRState();
}

class _SelfRState extends State<SelfR> {
  List _list = [];

  @override
  Widget build(BuildContext context) {
    return Container(
      
    );
  }

  void httpReq1(){
    http.get('http://m.maoyan.com/ajax/movieOnInfoList?token=').then((http.Response response){
      Map<String, dynamic> responseData =  json.decode(response.body);
      print('数据是${responseData["movieList"]}');
      setState(() {
        _list = responseData["movieList"];
      });
    }).catchError((error){
      print(error);
    });
  }

  void httpReq2 () async{
    try{
      http.Response response = await http.get('http://m.maoyan.com/ajax/movieOnInfoList?token=');
      Map<String, dynamic> responseData = json.decode(response.body);
      setState(() {
       _list = responseData["movieList"]; 
      });
    }catch(error){
      print(error);
    }

  }


  void dioReq() async {
    try{
      Dio dio = new Dio();
      Response response = await dio.get('http://m.maoyan.com/ajax/movieOnInfoList?token=');
      var data;
      data = json.decode(response.toString());
      setState(() {
       _list = data["movieList"]; 
      });
    }catch(error){
      print(error);
    }

  }


}